<%--
  Created by IntelliJ IDEA.
  User: dzw
  Date: 2018/3/19
  Time: 17:15
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%
  String path = request.getContextPath();
  String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
  String _id=request.getParameter("_");
  String jsessionid = session.getId();
%>

<style>
  #personReadTable p,#personReadTable hr{
    margin: 5px 0;
  }
  #personReadTable p{
    /*height: 17px;*/
    min-height: 17px;
  }
  #personReadTable td{
    text-align: center;
    vertical-align: middle !important;
  }
  #personReadTable{
    margin-top: 30px;
  }
  #personPhoto{
    max-width: 200px;
    max-height: 300px;
  }
</style>

<div class="panel" style="margin-bottom: 0">
  <form id="form_person_input" class="form-horizontal" style="position: relative">
    <input type="hidden" name="keyId" id="keyId" value="${person.id}"/>
    <input type="hidden" name="curDutyId" id="curDutyId" value=""/>
    <input type="hidden" name="isDirector" id="isDirector" value="${isDirector}"/>

    <div class="row">
    <div class="col-md-8 col-md-offset-2">

    <table class="table table-striped table-bordered table-responsive" id="personReadTable">
      <tbody id="personInfoTable">
      <tr>
        <td width="14%" >姓名</td>
        <td width="14%" >${person.name}</td>
        <td width="14%" >性别</td>
        <td width="14%" >${person.gender}</td>
        <td width="14%" >出生日期</td>
        <td width="14%" ><fmt:formatDate pattern="yyyy年MM月" value="${person.birthday}" /></td>
        <td width="16%"  rowspan="5">
          <c:if test="${person.photo!=null}">
            <img id="personPhoto" src="../common/file/download?${person.photo.url}">
          </c:if>
          <c:if test="${person.photo==null}">暂无</c:if>
        </td>
      </tr>
      <tr>
        <td>民族</td>
        <td>${person.nation.name}</td>
        <td>籍贯</td>
        <td>${person.origin}</td>
        <td>出生地</td>
        <td>${person.birthPlace}</td>
      </tr>
      <tr>
        <td>入党时间</td>
        <td><fmt:formatDate pattern="yyyy年MM月" value="${person.joinPartyDate}" /></td>
        <td>参加工作时间</td>
        <td><fmt:formatDate pattern="yyyy年MM月" value="${person.joinWorkDate}" /></td>
        <td>健康状况</td>
        <td>${person.health}</td>
      </tr>
      <tr>
        <td>熟悉专业有何专长</td>
        <td colspan="2">${person.specialty}</td>
        <td>身份证号</td>
        <td colspan="2">${person.cardId}</td>
      </tr>
      <tr>
        <td>工作性质</td>
        <td colspan="5">${person.workNature.name}</td>
      </tr>
      <c:if test="${isDirector==1}">
        <tr>
          <td>政治面貌</td>
          <td colspan="6">${person.zzmm}</td>
        </tr>
      </c:if>
      <tr>
        <td rowspan="3">学历学位</td>
        <td colspan="6">${person.highEdu.name}</td>
      </tr>
      <tr>
        <td>全日制教育</td>
        <td colspan="2">${person.allDayEdu.name}</td>
        <td>毕业院校系及专业</td>
        <td colspan="2">${person.allDaySchool}</td>
      </tr>
      <tr>
        <td>在职教育</td>
        <td colspan="2">${person.jobEdu.name}</td>
        <td>毕业院校系及专业</td>
        <td colspan="2">${person.jobSchool}</td>
      </tr>
      <tr>
        <td colspan="2">现任职务</td>
        <td colspan="2">${person.nowPost}</td>
        <td>现任职时间</td>
        <td colspan="2"><fmt:formatDate pattern="yyyy年MM月" value="${person.nowPostDate}" /></td>
      </tr>
      <tr>
        <td colspan="2">所在区</td>
        <td colspan="2">${person.area}</td>
        <td>所在街道</td>
        <td colspan="2">${person.street.name}</td>
      </tr>

      <tr>
        <%--<td rowspan="3">${person.generalDict==null?'2018-2021':person.generalDict.name}</td>--%>
        <td colspan="1">居民区</td>
        <td colspan="6">${person.resident.name}</td>
      </tr>
      <tr>
        <td colspan="1">是否为一肩挑</td>
        <td colspan="6">${person.shoulder==1?"是":"否"}  &nbsp;&nbsp; <c:if test="${person.shoulder==1}">${person.shoulderDet}</c:if></td>
      </tr>
      <tr>
        <td colspan="1">人员性质</td>
        <td colspan="6">${person.personNature.name}</td>
      </tr>

      <!-- 学历经历 -->
      <tr>
        <td rowspan="${fn:length(studyList)+1}">学习经历<br/>（自高中以来）</td>
        <td colspan="2">起止时间</td>
        <td colspan="3">学校</td>
        <td>所获学位</td>
      </tr>
      <c:forEach items="${studyList}" var="study" varStatus="index">
          <tr>
            <td colspan="2"><fmt:formatDate pattern="yyyy年MM月" value="${study.startDate}" /> - <fmt:formatDate pattern="yyyy年MM月" value="${study.endDate}" /></td>
            <td colspan="3">${study.school}</td>
            <td>${study.academicDegree}</td>
          </tr>
      </c:forEach>


      <%--<!-- 学历经历 -->--%>
      <%--<tr>--%>
        <%--<td rowspan="2">学习经历（自高中以来）</td>--%>
        <%--<td colspan="2">起止时间</td>--%>
        <%--<td colspan="3">学校</td>--%>
        <%--<td>所获学位</td>--%>
      <%--</tr>--%>
      <%--<tr>--%>
        <%--<td colspan="2" style="padding: 0">--%>
          <%--<c:forEach items="${person.studyList}" var="study" varStatus="index">--%>
            <%--<c:if test="${study.state=='Enable'}">--%>
              <%--<p>--%>
                <%--<fmt:formatDate pattern="yyyy年MM月" value="${study.startDate}" /> - <fmt:formatDate pattern="yyyy年MM月" value="${study.endDate}" />--%>
              <%--</p>--%>
              <%--<c:if test="${!index.last}"><hr/></c:if>--%>
            <%--</c:if>--%>
          <%--</c:forEach>--%>
          <%--<c:if test="${fn:length(person.studyList)==0}"><p>&nbsp;</p></c:if>--%>
        <%--</td>--%>
        <%--<td colspan="3" style="padding: 0">--%>
          <%--<c:forEach items="${person.studyList}" var="study" varStatus="index">--%>
            <%--<c:if test="${study.state=='Enable'}">--%>
              <%--<p>${study.school}</p>--%>
              <%--<c:if test="${!index.last}"><hr/></c:if>--%>
            <%--</c:if>--%>
          <%--</c:forEach>--%>
          <%--<c:if test="${fn:length(person.studyList)==0}"><p>&nbsp;</p></c:if>--%>
        <%--</td>--%>
        <%--<td style="padding: 0">--%>
          <%--<c:forEach items="${person.studyList}" var="study" varStatus="index">--%>
            <%--<c:if test="${study.state=='Enable'}">--%>
              <%--<p>${study.academicDegree}</p>--%>
              <%--<c:if test="${!index.last}"><hr/></c:if>--%>
            <%--</c:if>--%>
          <%--</c:forEach>--%>
          <%--<c:if test="${fn:length(person.studyList)==0}"><p>&nbsp;</p></c:if>--%>
        <%--</td>--%>
      <%--</tr>--%>


      <!-- 工作经历 -->
      <tr>
        <td rowspan="${fn:length(workList)+1}">工作经历</td>
        <td colspan="2">起止时间</td>
        <td colspan="2">工作单位及部门</td>
        <td>职务（职级）</td>
        <td>证明人</td>
      </tr>
      <c:forEach items="${workList}" var="work" varStatus="index">
        <tr>
          <td colspan="2"><fmt:formatDate pattern="yyyy年MM月" value="${work.workStartDate}" /> - <fmt:formatDate pattern="yyyy年MM月" value="${work.workEndDate}" /></td>
          <td colspan="2">${work.workDept}</td>
          <td>${work.workPost}</td>
          <td>${work.proveUser}</td>
        </tr>
      </c:forEach>

      <%--<!-- 工作经历 -->--%>
      <%--<tr>--%>
        <%--<td rowspan="2">工作经历</td>--%>
        <%--<td colspan="2">起止时间</td>--%>
        <%--<td colspan="2">工作单位及部门</td>--%>
        <%--<td>职务（职级）</td>--%>
        <%--<td>证明人</td>--%>
      <%--</tr>--%>
      <%--<tr>--%>
        <%--<td colspan="2" style="padding: 0">--%>
          <%--<c:forEach items="${person.workList}" var="work" varStatus="index">--%>
            <%--<c:if test="${work.state=='Enable'}">--%>
              <%--<p>--%>
                <%--<fmt:formatDate pattern="yyyy年MM月" value="${work.workStartDate}" /> - <fmt:formatDate pattern="yyyy年MM月" value="${work.workEndDate}" />--%>
              <%--</p>--%>
              <%--<c:if test="${!index.last}"><hr/></c:if>--%>
            <%--</c:if>--%>
          <%--</c:forEach>--%>
          <%--<c:if test="${fn:length(person.workList)==0}"><p>&nbsp;</p></c:if>--%>
        <%--</td>--%>
        <%--<td colspan="2" style="padding: 0">--%>
          <%--<c:forEach items="${person.workList}" var="work" varStatus="index">--%>
            <%--<c:if test="${work.state=='Enable'}">--%>
              <%--<p>${work.workDept}</p>--%>
              <%--<c:if test="${!index.last}"><hr/></c:if>--%>
            <%--</c:if>--%>
          <%--</c:forEach>--%>
          <%--<c:if test="${fn:length(person.workList)==0}"><p>&nbsp;</p></c:if>--%>
        <%--</td>--%>
        <%--<td style="padding: 0">--%>
          <%--<c:forEach items="${person.workList}" var="work" varStatus="index">--%>
            <%--<c:if test="${work.state=='Enable'}">--%>
              <%--<p>${work.workPost}</p>--%>
              <%--<c:if test="${!index.last}"><hr/></c:if>--%>
            <%--</c:if>--%>
          <%--</c:forEach>--%>
          <%--<c:if test="${fn:length(person.workList)==0}"><p>&nbsp;</p></c:if>--%>
        <%--</td>--%>
        <%--<td style="padding: 0">--%>
          <%--<c:forEach items="${person.workList}" var="work" varStatus="index">--%>
            <%--<c:if test="${work.state=='Enable'}">--%>
              <%--<p>${work.proveUser}</p>--%>
              <%--<c:if test="${!index.last}"><hr/></c:if>--%>
            <%--</c:if>--%>
          <%--</c:forEach>--%>
          <%--<c:if test="${fn:length(person.workList)==0}"><p>&nbsp;</p></c:if>--%>
        <%--</td>--%>
      <%--</tr>--%>

      <!-- 奖惩情况 -->
      <tr>
        <td>奖惩情况</td>
        <td colspan="6">${person.reward}</td>
      </tr>

      <!-- 家庭信息 -->
      <tr>
        <td rowspan="${fn:length(person.familyList) + (fn:length(person.familyList)==0?2:1)}">家庭主要成员及重要社会关系</td>
        <td>称谓</td>
        <td>姓名</td>
        <td>出生年月</td>
        <td>政治面貌</td>
        <td>学历学位</td>
        <td>工作单位及职务</td>
      </tr>
      <c:forEach items="${person.familyList}" var="family" varStatus="index">
        <c:if test="${family.state=='Enable'}">
          <tr>
            <td>${family.nickName}</td>
            <td>${family.familyName}</td>
            <td><fmt:formatDate pattern="yyyy年MM月" value="${family.familyBirthday}" /></td>
            <td>${family.politicalStatus}</td>
            <td>${family.familyEdu}</td>
            <td>${family.familyJob}</td>
          </tr>
        </c:if>
      </c:forEach>
      <c:if test="${fn:length(person.familyList)==0}">
        <tr>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
      </c:if>
      <tr>
        <td rowspan="2">家庭地址</td>
        <td rowspan="2" colspan="3">${person.familyAddress}</td>
        <td>联系电话</td>
        <td colspan="2">${person.phone}</td>
      </tr>
      <tr>
        <td>邮编</td>
        <td colspan="2">${person.zipCode}</td>
      </tr>
      </tbody>
    </table>

    </div>
    </div>

    <c:if test='${(person.processState=="Running" || person.processState=="Backed") && stepNo !=1 && stepNo !=0}'>
      <div class="form-group" id="comment">
        <label class="col-md-2 control-label">审批意见</label>
        <div class="col-md-6">
          <textarea name="editor" id="editor" style="height:200px;"></textarea>
        </div>
      </div>
    </c:if>

  </form>
</div>

<div class="panel-footer">
  <a class="btn btn-default" id="apply-re-common" href="javascript:void(0)">
    <i class="fa fa-lg fa-mail-reply"></i> 返回
  </a>
  <a class="btn btn-default" key="ajax_edit" href="javascript:void(0);" ${isEdit}>
    <i class="fa fa-lg fa-edit"></i> 编辑
  </a>
</div>

<div class="flow">
  <div class="f_title"><i class="right" id="flow"></i>流程信息</div>
  <div class="f_content" style="display:none">
    <div id="showFlow"></div>
  </div>
  <div class="f_title"><i class="right" id="next"></i>下一步骤提示</div>
  <div class="f_content" style="display:none">
    <div id="showNext"></div>
  </div>
</div>

<script>
  var index = "${index}";
  var todo = "${todo}";
  var remind = "${remind}";
  var record = "${record}";
  var draft =  "${draft}";
  var stepNo = "${stepNo}";

  $(function(){

    $("#form_person_input input,#form_person_input textarea").attr("readonly", true);

    loadURL("<%=path%>/com/running/workflow?bussinessId="+$("#form_person_input #keyId").val()+"&type=flow",$('#showFlow'));
    loadURL("<%=path%>/com/running/workflow?bussinessId="+$("#form_person_input #keyId").val()+"&type=next",$('#showNext'));
    __ajax_post("<%=path%>/com/running/operateType",{keyId: $("#form_person_input #keyId").val()},function(pdata){
      var showDuty = false;
      var area = $("div.panel-footer");
      var edit = null;
      if (stepNo == 1){
        return false;
      }
      $(pdata.datarows).each(function(i,v){
        var str = '<a id="left_foot_btn_'+ v.action+'" class="btn btn-warning" href="javascript:void(0);"><i class="fa fa-upload">'+ v.name+'</i></a>&nbsp;';
        $(area).append(str);
        if(v.action == "approve" || v.action=="sendback"  || v.action=="deny"){
          showDuty = true;
        }
      });
      if(showDuty == true){
        var pdata = {
          keyId: $("#form_person_input #keyId").val(),
          entityName: "com.fz.us.oa.core.entity.com.${isDirector==1?'Director':'Person'}"
        };
        multiDuty(pdata);
      }else{
        $('#comment').hide();
      }
      if($(':visible#editor').length == 1){
        edit  = new UE.ui.Editor();
        edit.render('editor');
      }
      //通过
      $("#left_foot_btn_approve").off("click").on("click",function(){
        var comment = "";
        if(edit != null){
          comment = encodeURIComponent(edit.getContent());
        }
        if($.trim(comment) == ""){
          alert("请填写审批意见");
          return false;
        }
        var stepNo = "${stepNo}";
        if(stepNo == "3"){
          var rs =  $("#form_person_input").valid();
          if(!rs){
            return false;
          }
        }
        __form_save("form_person_input","<%=path%>/com/person/approve?comment="+comment,function(){
          $("#apply-re-common").trigger("click");
        })
      });
      //退回
      $("#left_foot_btn_sendback").off("click").on("click",function(){
        var comment = "";
        if(edit != null){
          comment = encodeURIComponent(edit.getContent());
        }
        if($.trim(comment) == ""){
          alert("请填写审批意见");
          return false;
        }
        var vActionUrl="<%=path%>/com/person/back?comment="+comment+"&curDutyId="+$('#curDutyId').val();
        var data={keyId:$("input#keyId").val()};
        __ajax_post(vActionUrl,data,function(pdata){
          __toastr(pdata);
          $("#apply-re-common").trigger("click");
        });
      });
      //否决
      $("#left_foot_btn_deny").off("click").on("click",function(){
        var comment = "";
        if(edit != null){
          comment = encodeURIComponent(edit.getContent());
        }
        if($.trim(comment) == ""){
          alert("请填写审批意见");
          return false;
        }
        var vActionUrl="<%=path%>/com/person/deny?comment="+comment+"&curDutyId="+$('#curDutyId').val();
        var data={keyId:$("input#keyId").val()};
        __ajax_post(vActionUrl,data,function(pdata){
          __toastr(pdata);
          $("#apply-re-common").trigger("click");
        });
      });
    });

    //流程信息展开
    $('#flow,#next').click(function(){
      if($(this).hasClass("right")){
        $(this).removeClass("right").addClass("down");
        $(this).parent(".f_title").next("div.f_content").show();
      }else{
        $(this).removeClass("down").addClass("right");
        $(this).parent(".f_title").next("div.f_content").hide();
      }
    });
  });

  // 附件上传
  readLoad({
    objId:"photoName",
    entityName:"photoIds",
    sourceId:"photoId",
    jsessionid:"<%=jsessionid%>"
  });

  //返回视图
  $("#apply-re-common").click(function(){
    if(index==1){
      loadURL("menu/dashboard",$('#page-content'));
    }else if(todo==1){
      loadURL("menu/toDo",$('#page-content'));
    }else if(remind==1){
      loadURL("menu/remind",$('#page-content'));
    }else if(record==1){
      loadURL("menu/taskRecord?type=1",$('#page-content'));
    }else if(record==2){
      loadURL("menu/taskRecord?type=2",$('#page-content'));
    }else if(draft==1){
      loadURL("menu/draft",$('#page-content'));
    }else{
      returnToHashUrl()
    }
  });

  //编辑
  $("a[key=ajax_edit]").click(function(){
    loadURL("<%=path%>/com/person/input?keyId="+$("input#keyId").val()+"&isDirector="+$("#isDirector").val()+"&draft="+draft+"&todo="+todo+"&remind="+remind+"&record="+record+"&index="+index,$('#page-content'));
  });


</script>